<template>
    <div>
        <el-input
            v-model="modelValue.variableValue"
            :size="propJson.size"
            :style="execClass"
            :placeholder="propJson.placeHolder"
            :maxlength="propJson.isLengthLimit ? propJson.maxLength : -1"
            :show-word-limit="propJson.isLengthLimit"
            :disabled="propJson.isDisable"
            :clearable="propJson.isClearable"
            :type="propJson.isPassword ? 'password' : (propJson.isTextArea ? 'textarea' : '')"
            :autosize="autosizeRes"
        />
    </div>
</template>

<script>
export default {
    name: "InputComponent",
    props: ['propJson', 'commonParam'],
    computed: {
        execClass() {
            let resStyle = "width: 100%;"
            if (this.propJson.editFlag) {
                resStyle += "pointer-events: none;";
            }
            return resStyle;
        },
        modelValue() {
            for (let i = 0; i < this.commonParam.length; i++) {
                let info = this.commonParam[i];
                if (this.propJson.bindVariable === info.variableName) {
                    return info
                }
            }
            return {}
        },
        autosizeRes() {
            if (!this.propJson.isTextArea) {
                return false
            }
            if (this.propJson.isAutoSize) {
                return true
            }
            return {minRows: parseInt(this.propJson.textAreaMinRow), maxRows: parseInt(this.propJson.textAreaMaxRow)}
        }
    }
}
</script>

<style scoped lang="less">

</style>